package org.NooLab.glue.instances;




import org.NooLab.glue.components.ParticipantsUpLinkConnectorIntf;

import org.NooLab.utilities.logging.PrintLog;



	

public class SourcesUpLinkService extends 
											 ParticipantUpLinkServiceAbs 
								  implements 
								  			 ParticipantUpLinkServiceIntf {

	
	// constants ......................
	
	String servedRole = "SOURCE" ;
	
	
	// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	public SourcesUpLinkService( ParticipantFactory pFactory, PrintLog outprn){
		super();
		
		
		participantFactory = pFactory ;
		
		factoryProperties = participantFactory.factoryProperties ;
		
		if (outprn!=null){
			out = outprn;
		}
	}
	// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

	
	// ------------------------------------------------------------------------------
	
	
	public void setProcedureAddress( ParticipantsUpLinkConnectorIntf upLinkProcs ){
		upLinkProcedures =  upLinkProcs;
	}
	
	
	@Override
	public void start() {
		 
		if (started){
			return;
		}
		
		
		if (participantFactory.xRegistration==null){
			// return;
		}
		
		// MessageBoardParticipant implements ParticipantBaseIntf
		mbp = (MessageBoardParticipant)(participantFactory.getInstance());
		mbf = mbp.getMsgboardFactory() ;
		
		if ((mbp!=null) && (mbf!=null)){
											out.print(3, "starting uplink connection check...");
		
		    started = startUplinkCheckEngine( mbp.participantsRole);
		}
		
		if(started == false){
			out.printErr(2, "\n>>> starting uplink connection check failed. Server checking remains inactive.");
		}
		
	}


	@Override
	public void stop() {
		if (started == false){
			return;
		}
		
		
		out.print(3, "stopping uplink connection check.");
		
	}


	@Override
	public void postPoll(long transactionID, String secret) {
		 
		
	}

	
	// ------------------------------------------------------------------------------

	public String getServedRole() {
		return servedRole;
	}


	public void setServedRole(String servedRole) {
		this.servedRole = servedRole;
	}


	@Override
	public void setPeriodLength(int p) {


		setPeriodLengthBetweenPolls(p);		
	}

 
	
	
}



